package com.zivwu.mvp.pick;

import androidx.annotation.IntRange;

public class RequestCode {
    private static final int MODE_SHIFT = 13;
    private static final int MODE_MASK = 0x3 << MODE_SHIFT;


    public static final int CAMERA = 0 << MODE_SHIFT;
    public static final int ALBUM = 1 << MODE_SHIFT;
    public static final int CROP = 2 << MODE_SHIFT;


    public static int makeRequestCode(@IntRange(from = 0, to = (1 << RequestCode.MODE_SHIFT) - 1) int requestCode, int mode) {
        return requestCode + mode;
    }


    public static int getMode(int measureSpec) {
        return (measureSpec & MODE_MASK);
    }

    public static int getCode(int measureSpec) {
        return (measureSpec & ~MODE_MASK);
    }

}
